package cn.sccl.test;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;

import cn.sccl.domain.Customer;
import cn.sccl.utils.HibernateUtils;

/**
 * @author 饶爽
 * @time 2019年8月25日 下午9:22:11
 * @version 1.0.0
 * 主键生成策略测试类
*/
public class GeneratorDemo {
    @Test
    //保存客户信息
    public void fun1() {
        //1.获得session
        Session session = HibernateUtils.openSession();
        //2.控制事务
        Transaction transaction = session.beginTransaction();
        //3.执行操作
        Customer customer = new Customer();
        customer.setCust_name("华为");
        
        Customer customer2 = new Customer();
        customer2.setCust_name("鸿蒙");
        
        session.save(customer);
        session.save(customer2);
        //4.提交事务,关闭资源
        transaction.commit();
        session.close();
    }
}
